from django.http import JsonResponse
from LogisticsCard.models import Cards
from django.views.decorators.http import require_GET

@require_GET
def card_search_api(request):
    q = request.GET.get('q', '')
    cards = Cards.objects.filter(iccid__icontains=q, delete_at__isnull=True)[:10]
    return JsonResponse([{'id': c.id, 'iccid': c.iccid} for c in cards], safe=False)
